package org.barad.architecture.analyzer.archpad.component;

import javax.swing.Icon;

import org.barad.architecture.analyzer.archpad.ArchPad;

/**
 * This class serves as a base for components of the user defined
 * model used by {@link ArchPad}. It contains the minimal set of 
 * properties for building architectural model of connected 
 * components without making any assumptions about their type,
 * number, etc.
 * 
 * @author svetoslavganov@gmail.com (Svetoslav R. Ganov)
 *
 */

public class ArchPadComponent extends AcrhPadBasicComponent implements Cloneable {
	protected String name;
	protected boolean linkMandatory;
	protected String iconFileName;
	protected Icon icon;

	/**
	 * @see Object#clone()
	 */
	@Override
	public Object clone() {
		ArchPadComponent clone = (ArchPadComponent)super.clone();
		//this is not cloned with purpose
		clone.icon = icon;
		clone.iconFileName = iconFileName;
		clone.linkMandatory = linkMandatory;
		clone.name = name;
		return clone;
	}
	
	/**
	 * @see Object#toString()
	 */
	@Override
	public String toString() {
		return name;
	}
	
	/**
	 * Gets the component name.
	 * 
	 * @return The name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the component name.
	 * 
	 * @param name The name.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Gets the name of the component {@link Icon}.
	 * 
	 * @return The icon name.
	 */
	public String getIconFileName() {
		return iconFileName;
	}

	/**
	 * Sets the name of the component {@link Icon}.
	 * 
	 * @param iconFileName The icon name.
	 */
	public void setIconFileName(String iconFileName) {
		this.iconFileName = iconFileName;
	}

	/**
	 * Gets the component {@link Icon}.
	 * 
	 * @return The {@link Icon}.
	 */
	public Icon getIcon() {
		return icon;
	}

	/**
	 * Sets the component {@link Icon}.
	 * 
	 * @param icon The {@link Icon}.
	 */
	public void setIcon(Icon icon) {
		this.icon = icon;
	}
	
	/**
	 * Gets if the component must be one of the sides
	 * in a component link.
	 * 
	 * @return If the component is must a side in a link.
	 */
	public boolean isLinkMandatory() {
		return linkMandatory;
	}

	/**
	 * Sets if the component must be one of the sides
	 * in a component link.
	 * 
	 * @param linkMandatory If the component is must a 
	 *        side in a link.
	 */
	public void setLinkMandatory(boolean linkMandatory) {
		this.linkMandatory = linkMandatory;
	}
}
